//
//  BYLoginTextField.m
//  OCDemo
//
//  Created by zhumuzhi on 2022/2/13.
//

#import "BYLoginTextField.h"

@interface BYLoginTextField()

@property (nonatomic , assign) CGPoint endPoint;
@property (nonatomic , assign) CAShapeLayer *lineLayer;

@end

@implementation BYLoginTextField


- (instancetype)initWithFrame:(CGRect)frame lineWidth:(CGFloat)lineWidth {
    if (self = [super initWithFrame:frame]) {
        self.tintColor = PUBLIC_ORANGE_COLOR;
        self.textColor = UIColorFromRGB(0x333333);
        self.font = MZFont(16);
        self.endPoint = CGPointMake(lineWidth, self.height);
    }
    return self;
}

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.tintColor = PUBLIC_ORANGE_COLOR;
        self.textColor = UIColorFromRGB(0x333333);
        self.font = MZFont(16);
        self.endPoint = CGPointMake(kScreenWidth - self.x * 2, self.height);
    }
    return self;
}

- (void)drawRect:(CGRect)rect {
    if (self.lineLayer) {
        return;
    }
    UIBezierPath *path = [UIBezierPath bezierPath];
    [path moveToPoint:CGPointMake(0,self.height)];
    [path addLineToPoint:self.endPoint];
    CAShapeLayer *layer = [CAShapeLayer layer];
    layer.lineWidth = 1;
    layer.strokeColor = UIColorFromRGB(0xE4E4E4).CGColor;
    layer.path = path.CGPath;
    layer.fillColor = nil;
    [self.layer addSublayer:layer];
    self.lineLayer = layer;
}


@end
